package com.pcbly.web.components.taglib.tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;

import com.opensymphony.xwork2.util.ValueStack;
import com.pcbly.web.components.taglib.TextField;

public class TextFieldTag extends BaseTag {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3721913900469913371L;
	protected String type;
	protected String size;
	protected String maxLength;
	protected String readonly;
	
	@Override
	public Component getBean(ValueStack stack, HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		return new TextField(stack);
	}
	protected void populateParams() { 
		super.populateParams();
		type=getStringValue(type);
		
		size=getStringValue(size);
		maxLength=getStringValue(maxLength);
		readonly=getStringValue(readonly);
		
		TextField text = (TextField)component; 
		text.setCssClass(cssClass);
		
		text.setKey(key);
		text.setId(id);
		text.setCssClass(cssClass);
		text.setCssStyle(cssStyle);
		text.setDisabled(disabled);
		text.setName(name);
		text.setRequired(required);
		text.setTabindex(tabindex);
		text.setValue(value);
		text.setTitle(title);
		text.setType(type);
		text.setSize(size);
		text.setMaxLength(maxLength);
		text.setReadonly(readonly);

		// HTML scripting events attributes
		text.setOnclick(onclick);
		text.setOndblclick(ondblclick);
		text.setOnmousedown(onmousedown);
		text.setOnmouseup(onmouseup);
		text.setOnmouseover(onmouseover);
		text.setOnmousemove(onmousemove);
		text.setOnmouseout(onmouseout);
		text.setOnfocus(onfocus);
		text.setOnblur(onblur);
		text.setOnkeypress(onkeypress);
		text.setOnkeydown(onkeydown);
		text.setOnkeyup(onkeyup);
		text.setOnselect(onselect);
		text.setOnchange(onchange);
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getSize() {
		return size;
	}
	public void setSize(String size) {
		this.size = size;
	}
	public String getMaxLength() {
		return maxLength;
	}
	public void setMaxLength(String maxLength) {
		this.maxLength = maxLength;
	}
	public String getReadonly() {
		return readonly;
	}
	public void setReadonly(String readonly) {
		this.readonly = readonly;
	}
	
}
